package com.test.mooan.labama.utils_boom;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;


public class Permissionutil_boom {

    public static final int Permission_Code_Phonestate = 953;
    public static final int Permission_Code_Camera = 407;
    public static final int Permission_Code_Sms = 889;

    public static final String[] AllPermissions = {Manifest.permission.READ_SMS};

    //检查权限是否全部获取
    public static boolean checkPermissions(@NonNull Activity activity, String... permissions) {

        try {
            for (String permission:permissions){
                if (PackageManager.PERMISSION_GRANTED != ContextCompat.checkSelfPermission(activity, permission)) {
                    Log.d(Permissionutil_boom.class.getSimpleName(), "checkPermissions: "+permission);
                    return false;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return true;
    }

    public static boolean checkAllPermissions(Activity activity){

        return checkPermissions(activity,AllPermissions);
    }

}
